package com.sphd.Restaurant.adapters;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;


import com.sphd.Restaurant.R;
import com.sphd.Restaurant.infos.IntegralInfo;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Hu on 2016/10/11.
 */

public class ScoreAdapter extends BaseAdapter {

    List<IntegralInfo> myList;

    public ScoreAdapter(List<IntegralInfo> myList) {
        this.myList = myList;
    }

    @Override
    public int getCount() {
        return myList.size();
    }

    @Override
    public Object getItem(int position) {
        return myList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup viewGroup) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = View.inflate(viewGroup.getContext(), R.layout.item_score, null);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.scoreContent.setText(myList.get(position).getDishes_name());
        viewHolder.needScore.setText(myList.get(position).getMember_integral()+"积分");


        return convertView;
    }

    static class ViewHolder {
        @BindView(R.id.score_content)
        TextView scoreContent;
        @BindView(R.id.need_score)
        TextView needScore;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
